/**
 * Created by walkman on 2017/7/18.
 */

'use strict';

(function () {
  angular.module('WfbPlatformApp').controller('MenuController',
    ['$rootScope', '$scope', '$http', '$compile', '$window', 'http', '$q', 'authService', 'loginService',
      function ($rootScope, $scope, $http, $compile, $window, http, $q, authService, loginService) {

        $scope.userInfo = {};


        $scope.$on('$viewContentLoaded', function () {


        });

        $scope.$on('$includeContentLoaded', function () {

        });

        $scope.getUserInfo = function () {

          var promise = authService.getUserInfo({});
          promise.then(function success(result) {
            //成功回调
            $scope.userInfo = angular.copy(result.data);
          }, function error(error) {
            //错误回调
            // console.log(JSON.stringify(error));
          });
        };

        $scope.logout = function () {
          var promise = loginService.logout({});
          promise.then(function success(result) {
            //成功回调
            $window.location.href = '/login.html';
          }, function error(error) {//错误回调
            // console.log(JSON.stringify(error));
          });
        };

        $scope.getUserInfo();

      }]);
})();
